package com.example.controller;


import com.example.entity.FirstVO;
import com.example.entity.Result;
import com.example.entity.Second;
import com.example.service.ISecondService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 第二标签表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-11
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/second")
@Slf4j
@CrossOrigin
public class SecondController {

    private final ISecondService iSecondService;

    @DeleteMapping("/delete")
    public Result delete(@RequestParam List<Long> ids) throws Exception {
        log.info("批量删除二级标签：{}",ids);
        iSecondService.delete(ids);
        return Result.success();
    }

    @PostMapping("/save")
    public Result save(@RequestBody Second second){
        iSecondService.save(second);
        return Result.success();
    }

    @GetMapping("/select")
    public Result<List<FirstVO>> sel(){
        log.info("二级标签查询");
        List<FirstVO> list = iSecondService.select();
        return Result.success(list);
    }
}
